package com.dsunsoft.rtu.web;


import com.dsunsoft.rtu.common.entity.RestCode;
import com.dsunsoft.rtu.common.entity.RestResult;
import com.dsunsoft.rtu.common.vo.NgTreeVO;
import com.dsunsoft.rtu.core.base.BaseRestController;
import com.dsunsoft.rtu.dto.SysMenuTreeDto;
import com.dsunsoft.rtu.entity.SysMenu;
import com.dsunsoft.rtu.query.SysMenuQuery;
import com.dsunsoft.rtu.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 城市 Controller 实现 Restful HTTP 服务
 * <p>
 * Created by x on 2018-7-13
 */
@RestController
@RequestMapping(value = "/api/sysMenu")
public class SysMenuController extends BaseRestController<SysMenu, SysMenuQuery> {

    @Autowired
    private SysMenuService sysMenuService;

    @PostMapping(value = "/getTree")
    public RestResult<List<SysMenuTreeDto>> getPage(@RequestBody SysMenuQuery query) {
        List<SysMenuTreeDto> list = sysMenuService.selectListTree(query);
        return new RestResult<>(RestCode.SUCCESS, list);
    }


    @GetMapping(value = "/getAll")
    public RestResult<List<SysMenu>> getAll(@RequestBody SysMenuQuery query) {
        List<SysMenu> list = sysMenuService.queryList(query);
        return new RestResult<List<SysMenu>>(RestCode.SUCCESS, list);
    }

    @PostMapping(value = "/getChooseTree")
    public RestResult<List<NgTreeVO>> getChooseTree(@RequestBody SysMenuQuery query) {
        List<NgTreeVO> list = sysMenuService.selectNzTree(query);
        return new RestResult<>(RestCode.SUCCESS, list);
    }
}
